package com.wanchuang.qhbb.adapter;

import android.content.Context;
import android.graphics.Color;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.wanchuang.qhbb.R;
import com.wanchuang.qhbb.proto.Recharge;
import com.ruffian.library.widget.RTextView;

public class AccountAdapter extends BaseQuickAdapter<Recharge.My_earnings.wallet_list, BaseViewHolder> {
    private int[] bgColors = {R.mipmap.bg_yello_three, R.mipmap.bg_red_one, R.mipmap.bg_blue_two};
    private int[] bgColors2 = {R.mipmap.bg_yello_three2, R.mipmap.bg_red_one2, R.mipmap.bg_blue_two2};
    private int[] qianBg = {R.mipmap.icon_qian_lan, R.mipmap.icon_qian_lan, R.mipmap.icon_qian_lv};
    private String[] textColors = {"#FF1E79EB", "#FF7864F4", "#FF1DA2A5"};

    public AccountAdapter(Context context) {
        super(R.layout.item_account);
    }

    @Override
    protected void convert(BaseViewHolder helper, Recharge.My_earnings.wallet_list item) {
        int bgColor = helper.getLayoutPosition() % 3;
        helper.setBackgroundResource(R.id.ll_account_bg, bgColors[bgColor]);
        helper.setBackgroundResource(R.id.iv_bg_two, bgColors2[bgColor]);
        helper.setBackgroundResource(R.id.iv_qian, qianBg[bgColor]);
        helper.<RTextView>getView(R.id.tv_type_one).setText(item.getWalletName().substring(1,2));
        helper.<RTextView>getView(R.id.tv_type_one).getHelper().setTextColorNormal(Color.parseColor(textColors[bgColor]));


        helper.setText(R.id.tv_type, item.getWalletName())
                .setTextColor(R.id.tv_money_one, Color.parseColor(textColors[bgColor]))
                .setText(R.id.tv_money_one, "￥" + item.getBalance());
        helper.setText(R.id.tv_money_tow, "￥" + item.getAvailable()).
                setTextColor(R.id.tv_money_tow, Color.parseColor(textColors[bgColor]));
        if (item.getAvailable().length() == 0) {
            helper.setGone(R.id.tv_money_tow, true)
                    .setGone(R.id.tv_message_two, true);
        } else {
            helper.setGone(R.id.tv_money_tow, false)
                    .setGone(R.id.tv_message_two, false);
        }
    }

}
